package com.lanelu.hencoderplusstudy.view.practice;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.View;

import androidx.annotation.Nullable;

/**
 * 画直方图
 */
public class Practice10HistogramView extends View {

    private Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);

    public Practice10HistogramView(Context context) {
        super(context);
    }

    public Practice10HistogramView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    public Practice10HistogramView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);
        paint.setColor(Color.GREEN);
        canvas.drawRect(100f, 498f, 150f, 500f, paint);
        canvas.drawRect(200f, 490f, 250f, 500f, paint);
        canvas.drawRect(300f, 300f, 350f, 500f, paint);
        canvas.drawRect(400f, 200f, 450f, 500f, paint);
        canvas.drawRect(500f, 100f, 550f, 500f, paint);
        canvas.drawRect(600f, 400f, 650f, 500f, paint);
        canvas.drawRect(700f, 400f, 750f, 500f, paint);

//        综合练习
//        练习内容：使用各种 Canvas.drawXXX() 方法画直方图
    }
}
